<?php 
include('header.php');
$_SESSION['return_url_pick']=newcurPageURL();
$testarr = array("");

 		if(isset ($_POST['keyword']))
		{
			$_SESSION['keyword']=$_POST['keyword']  ;
		}
		 if(isset ($_POST['workstyle']))
		{
			$_SESSION['workstyle']=$_POST['workstyle']  ;
		}
		 if(isset ($_POST['location']))
		{
			$_SESSION['location']=$_POST['location']  ;
		}
?>

                                         
                                         <?php
										 		$resultsl = $wpdb->get_results("SELECT  * FROM workstyle  "); 	
												$resultsc = $wpdb->get_results("SELECT  CategoryName FROM jobcategory  "); 
												$resultslw = $wpdb->get_results("SELECT  Location FROM location  "); 
										  ?>
                                          
<?php 
		$sql_str="select * from job where 1 ";
		if(isset($_POST['submit']))
		{
			if(isset($_POST['keyword'])&&$_POST['keyword']!=""){$jobtitle =$_POST['keyword'];}
			if(isset($_POST['workstyle'])&&$_POST['workstyle']!="Any Workstyle"){$workstyle=$_POST['workstyle'];}
			if(isset($_POST['location'])&&$_POST['location']!="Any Location"){$location =$_POST['location'];}
			if(isset($_POST['category'])&&$_POST['category']!="Any Category"){$JobCategory =$_POST['category'];}

			
			if($jobtitle!="")
			{ 
				$sql_str.="and (JobTitle LIKE '%".$jobtitle."%' OR ComName LIKE '%".$jobtitle."%'  
												OR JobType LIKE '%".$jobtitle."%'  OR JobDesc LIKE '%".$jobtitle."%'  
												OR WorkPlace LIKE '%".$jobtitle."%' OR SalaryRange LIKE '%".$jobtitle."%' )";  
											
			}
			
			$flag_location=false;
			
			for($i_location_search=0;$i_location_search<= (int)$_POST['i_location'];$i_location_search++)
			{
				
				if(isset($_POST['location'.$i_location_search]) && ($_POST['location'.$i_location_search]))
				{
					$flag_location=true;//$sql_str.=" or WorkPlace LIKE '%".$_POST['location'.$i_location_search]."%'" ;
				}
				
			}
			
			
			if($flag_location)
			{
				$sql_str.="and ( 0 ";
				for($i_location_search=0;$i_location_search<= (int)$_POST['i_location'];$i_location_search++)
			{
				
				if(isset($_POST['location'.$i_location_search]) && ($_POST['location'.$i_location_search]))
				{
					$sql_str.=" or WorkPlace LIKE '%".$_POST['location'.$i_location_search]."%'" ;
				}
				
			}
				$sql_str.=" or WorkPlace LIKE '%Any%') ";
			}
			
			$flag_workstyle=false;
			
			for($i_workstyle_search=0;$i_workstyle_search<= (int)$_POST['i_workstyle'];$i_workstyle_search++)
			{
				
				if(isset($_POST['workstyle'.$i_workstyle_search]) && ($_POST['workstyle'.$i_workstyle_search]))
				{
					$flag_workstyle=true;//$sql_str.=" or JobType='".$_POST['workstyle'.$i_workstyle_search]."' ";
				}
				
			}
			if($flag_workstyle)
			{
				$sql_str.="and ( 0 ";
				
				for($i_workstyle_search=0;$i_workstyle_search<= (int)$_POST['i_workstyle'];$i_workstyle_search++)
			{
				
				if(isset($_POST['workstyle'.$i_workstyle_search]) && ($_POST['workstyle'.$i_workstyle_search]))
				{
					$sql_str.=" or JobType='".$_POST['workstyle'.$i_workstyle_search]."' ";
				}
				
			}
				
				$sql_str.=" or JobType='5') ";
				
			}
			
			
			$flag_category=false;
			
			for($i_jobcategory_search=0;$i_jobcategory_search<= 11 ;$i_jobcategory_search++)
			{
				
				if(isset($_POST['category'.$i_jobcategory_search]) && ($_POST['category'.$i_jobcategory_search]))
				{
					$flag_category=true;//$sql_str.=" or JobCat ='".$_POST['category'.$i_jobcategory_search]."' ";
				}
				
			}
			
			
			if($flag_category)
			{
				$sql_str.="and ( 0 ";
				for($i_jobcategory_search=0;$i_jobcategory_search<= 11 ;$i_jobcategory_search++)
			{
				
				if(isset($_POST['category'.$i_jobcategory_search]) && ($_POST['category'.$i_jobcategory_search]))
				{
					$sql_str.=" or JobCat ='".$_POST['category'.$i_jobcategory_search]."' ";
				}
				
			}
				$sql_str.=" ) ";
			}
			
		}
		$sql_str.="And Deadline>curdate() and Status = 'valid' Order by Job_ID Desc ";
		
		  $results = sql($sql_str);
?>



   

    <script type="text/javascript">
    var oListBox;
    window.onload = function()
    {        
        var Arguments = {
            Base: document.getElementById('base'),
            Rows: 3,
            Width: 300,
            NormalItemColor: null,
            NormalItemBackColor: null,
            AlternateItemColor: null,
            AlternateItemBackColor: null,
            SelectedItemColor: null,
            SelectedIItemBackColor: null,
            HoverItemColor: null,
            HoverItemBackColor: null,
            HoverBorderdColor: null,
            ClickEventHandler: OnClick
        };
        
        oListBox = new ListBox(Arguments); 

        oListBox.AddItem('CodeProject.com','http://www.codeproject.com');
        oListBox.AddItem('yahoo.com','http://www.yahoo.com/');
        oListBox.AddItem('microsoft.com','http://www.microsoft.com/en/us/default.aspx');
        oListBox.AddItem('asp.net','http://www.asp.net');
        oListBox.AddItem('cricinfo.com','http://www.cricinfo.com/');
        oListBox.AddItem('AOL','http://www.aol.com/');
        oListBox.AddItem('STPL','http://stpl.biz');
    }
    
    var OnClick = function(Sender, EventArgs)
    {
        var Message = new Array();
        
        Message.push('IsSelected: ' + Sender.checked.toString());
        Message.push('Text: ' + EventArgs.Text);
        Message.push('Value: ' + EventArgs.Value);
        Message.push('Index: ' + EventArgs.ItemIndex);
        
        document.getElementById('DivMessage').innerHTML = Message.join('<br />');
    }
    
    window.onunload = function(){oListBox.Dispose(); }
    </script>
		<div id="primary">
			<div id="content" role="main">
				<article id="post-0" class="post no-results not-found">
				<form id="formRegis" name="formRegis" action="<?php bloginfo('siteurl')?>/index.php" method="post">
					<div class="search-on">
                    <div class="fix-search ">
							<h1 class="submenusearch"><?php echo $can_index_findjob;?></h1>
                            </div>
						<div class="fix-search ">
							<h2 class="title"><?php echo $can_in_cate ?></h2>
							<div class="category_fix" >
                            	 <table id="tb_Regis " class="secan2" cellpadding="5px">
                                 <tr> 
                                                 <td>
                                                		 <div class="checkwithlow">
                                                   		<input type="checkbox" name="category0"   value="Software / Web Development"  />
                                                         </div>
                                                        <div class="withlow">Software / Web Development</div>
                                                 </td>
                                                 <td>
                                                  <div class="checkwithlow">
                                                     <input type="checkbox" name="category1"   value="PM / BSE"  />
                                                       </div>
                                                        <div class="withlow">PM / BSE</div>
                                                 </td>
                                                 <td>
                                                         <div class="checkwithlow">
                                                     <input type="checkbox" name="category5"   value="SEO / Digital Marketing"  />
                                                       </div>
                                                        <div class="withlow">SEO / Digital Marketing</div>
                                                 </td>
                                  </tr>
                                   <tr>
                                                 <td>
                                                  <div class="checkwithlow">
                                                   	<input type="checkbox" name="category3"   value="Network / Server / Database"  />
                                                      </div>
                                                        <div class="withlow">Network / Server / Database</div>
                                                 </td>
                                                 <td>
                                                   <div class="checkwithlow">
                                                     <input type="checkbox" name="category4"   value="Admin / HR / Accounting / Legal"  />
                                                       </div>
                                                        <div class="withlow">
                                                     Admin / HR / Accounting / Legal</div>
                                                 </td>
                                                 <td>
                                                  <div class="checkwithlow">
                                                     <input type="checkbox" name="category8"   value="Web / Graphic Design"  />
                                                       </div>
                                                        <div class="withlow">Web / Graphic Design</div>
                                                 </td>
                                  </tr>
                                  <tr>
                                                 <td>
                                                   <div class="checkwithlow">
                                                   <input type="checkbox" name="category6"   value="Test / Quanlity Assurance"  />
                                                     </div>
                                                        <div class="withlow">Test / Quanlity Assurance</div>
                                                 </td>
                                                 <td>
                                                   <div class="checkwithlow">
                                                     <input type="checkbox" name="category7"   value="Translation / Interprelation"  />
                                                       </div>
                                                        <div class="withlow">Translation / Interprelation</div>
                                                 </td>
                                                 <td>
                                                     <div class="checkwithlow">
                                                   <input type="checkbox" name="category10"   value="Others"  />
                                                     </div>
                                                        <div class="withlow">Others</div>
                                                 </td>
                                  </tr>
                                  <tr>
                                                 <td>
                                                   <div class="checkwithlow">
                                                   <input type="checkbox" name="category9"   value="User / Customer Services"  />
                                                     </div>
                                                        <div class="withlow">User / Customer Services</div>
                                                 </td>
                                                 <td>
                                                  <div class="checkwithlow">
                                                         <input type="checkbox" name="category2"   value="Sales / Business Development"  />
                                                           </div>
                                                        <div class="withlow">Sales / Business Development</div>
                                                 </td>
                                                 <td>
                                                 	
                                                     
                                                 </td>
                                  </tr>
                                 
								 </table>
							</div>
					</div><!-- category -->
                    <div class="fix-search"> 
					<div class="fix-search-2 left location">
							<h2 class="title"><?php echo $can_in_location ?></h2>
                        		<div id="base">
                                </div>
                                <div id="DivMessage">          
                                </div>
							<div class="checkloca" id="location-check" >
                            							<div id="base">
                                                       
                              	 <?php
														$i_location=0;
															foreach($resultslw as $result)
															{
																 if($_SESSION['location']==$result->Location)
																	 {
																		 ?>
																	<input  type="checkbox" name="location<?php echo $i_location;?>"   value="<?php echo $result->Location ?>"  />
																	<span class="textmodify"><?php echo $result->Location ?></span><br />
																	<?php }
																else if(!in_array($result->Location,$testarr))
																{
																	array_push($testarr,$result->Location);
															?>
																	  
																		<input type="checkbox" name="location<?php echo $i_location;?>"  value="<?php echo $result->Location ?>" />
																	<span class="textmodify"><?php echo $result->Location ?></span><br />
																	<?php   $temp = $result->Location; ?>
															<?php
																}
																$i_location++;
															 } 
															?>
                                                              </div>
                                                  
                                          	
							</div>
					</div><!-- location-->
					<div class="fix-search-2 right workstyle" id="fix-search-2" style="margin-right:0px;" >
							<h2 class="title"><?php echo $can_in_workstyle ?></h2>
							<div class="checkloca" id="workstyle-check" >
                          									
                                    <?php
															$i_workstyle=0;
															foreach($resultsl as $result2)
															{
																
																		 ?>
																	<input type="checkbox" name="workstyle<?php echo $i_workstyle; ?>"    value="<?php echo $result2->workstyle ?>"  />
																	<span class="textmodify">
																	<?php  
																				echo my_translate('workstyle','workstyle',$result2->workstyle);
																				
																			 ?>
                                                                    </span><br />
																	
															<?php
																
																$i_workstyle++;  ?>
                                                               
															<?php } 
															?>
                                                             <input type="hidden" name="i_location" value="<?php echo $i_location; ?>" />
                                                              <input type="hidden" name="i_workstyle" value="<?php echo $i_workstyle; ?>" />
							</div>
					</div><!-- workstyle--></div>
					<div class="fix-search search-keyword">
						<h2 class="title addtitle" style="height: 22px !important;"><?php echo $can_in_key ?></h2>
							<div class="search-from">
							<input type="text" class="txt_class" name="keyword" value="<?php echo $_SESSION['keyword'];?>" />
							<input style="background-image: url('images/search-button-<?php echo $_SESSION['lang']; ?>.png');" type="submit" class="submit" value="Search" name="submit"/>
							</div>
					</div>
					</div>
					<header class="entry-header">
						<h1 class="entry-title"><?php echo $can_in_title ?></h1>
					</header><!-- .entry-header -->

					<div class="entry-content">
                   <?php 
                    if(mysql_num_rows($results)>0) { ?>
                    
				<table  class="table-new sortable">
                                        <thead>
                                            <tr class="sort">
                                                <th style="width:188px;"  class="sorttable_sorted_reverse"><?php echo $can_in_name ?><span id="sorttable_sortrevind"></span><img src="<?php bloginfo('template_url')?>/images/icon-sort.png" alt="" /></th>
                                                <th style="width:90px;" class=""><?php echo $can_in_workstyle ?><span></span><img src="<?php bloginfo('template_url')?>/images/icon-sort.png" alt="" /></th>
                                                <th style="width:80px;" class=""><?php echo $can_in_salary ?><span></span><img src="<?php bloginfo('template_url')?>/images/icon-sort.png" alt="" /></th>
                                                <th style="width:195px;" class="sorttable_sorted sorttable_sorted_reverse"><?php echo $can_in_outline ?><span></span></th>
												<th style="width:90px;" class=""><b><?php echo $can_in_location ?></b><span></span><img src="<?php bloginfo('template_url')?>/images/icon-sort-c.png" alt="" /></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                       
                                         		<?php	
										 $i=0;
					 while ($res=mysql_fetch_object($results))
						{
						
					?>
									
                                    <?php if ($i <= 4) { ?>
                                      <tr class="<?php if($i % 2 == 1){echo'white ';}elseif($i % 2 != 1){echo 'white ';} $i++; ?>
                                      	<?php
									  $temp =$res->JobType;
									 if( $temp=='Part-time'){
										echo 'part-time';
									 } ?>
                                      ">  
															   
                                	   <td >
									   <a href="<?php bloginfo('siteurl')?>/index.php/detail-job/?id=<?php echo  $res->Job_ID; ?> ">
											<?php
                                                 echo $res->JobTitle;
												 ?>
										</a>
											 
                                             <?php
											 echo '<br/>';
											 echo $res->ComName;
											 
										?></td>
                                	 <td><?php
									 
										  echo my_translate('workstyle','workstyle',$res->JobType);
										?></td>
                                	   <td><?php
										  echo $res->SalaryRange;
										?></td>
                                	   <td><div class="overlow">
									   <?php
											 echo $res->JobDesc;
										?></div>
                                        </td>
                                	  <td><?php
											  echo $res->WorkPlace;
										?></td>
                                	    <td > 
										 <td><br /><a href="<?php bloginfo('siteurl')?>/index.php/pick-up/?id=<?php echo  $res->Job_ID; ?> ">
                                         			<img src="<?php bloginfo('template_url')?>/images/pickup.png" alt="" /></a><br />
                                                    
                                                </a>    
                                                
                                          </td>
                                          
                              	    </tr>
                                   
                                        <?php
                      
						} }
                        ?>
                                  
									</tbody>                                
                                	  
                              	  <tfoot></tfoot></table>
                                  
                            <?php }
							  else
							  {
								  echo '<h1 style="font-size : 20px;">"'. $No_job_found.'" </h1>';
							  }
							  ?>     
                                    
					</div><!-- .entry-content -->
                    </form>
				</article><!-- #post-0 -->


			</div><!-- #content -->
		</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>